package test

import (
	"jiance_server/log"
	"jiance_server/model"
	"jiance_server/mongo"
	"jiance_server/util"

	"github.com/cdongyang/library/utils"
	mgo "gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

var Account = "441721199700000000"
var Account1 = "441721199700000001"
var Password = "123456"
var encodePwd = util.EncodePwd(Password)

func init() {
	utils.PanicError(mongo.Users.WithC(func(c *mgo.Collection) error {
		bulk := c.Bulk()
		bulk.Upsert(
			bson.M{"_id": Account},
			bson.M{"$set": model.User{
				ID:       Account,
				Password: encodePwd,
				Nickname: "dy",
			}},
			bson.M{"_id": Account1},
			bson.M{"$set": model.User{
				ID:       Account1,
				Password: encodePwd,
				Nickname: "js",
			}},
			bson.M{"_id": "441721199700000002"},
			bson.M{"$set": model.User{
				ID:       "441721199700000002",
				Password: encodePwd,
				Nickname: "ja",
			}},
		)
		res, err := bulk.Run()
		log.Logln("upsert users", res)
		return err
	}))

}
